import Vue from 'vue';
import VueRouter from "vue-router"

Vue.use(VueRouter)
const router = new VueRouter({
  mode: "hash",
  routes: [
    {
      path: "/",
      redirect: "/index",
    },
    {
      path: "/index",
      name: "index",
      component: () => import("@/views/IndexPage/index.vue"),
      meta: {
        title: '首页_西安旅游网', // 页面标题
        // keepAlive: true, // 页面是否需要被缓存
      },
    },
    {
      path: "/talent-travels",
      name: "talent-travels",
      component: () => import("@/views/News2/index.vue"),
      meta: {
        title: '旅游头条_西安旅游网', // 页面标题
      },
    },
    {
      path: "/scenic-news",
      name: "scenic-news",
      component: () => import("@/views/News/index.vue"),
      meta: {
        title: '景区动态_西安旅游网', // 页面标题
      },
    },
    {
      path: "/news-details",
      name: "news-details",
      component: () => import("@/views/NewsDetail/index.vue"),
      meta: {
        title: '新闻详情_西安旅游网', // 页面标题
      },
    },
    {
      path: "/play-xian",
      name: "play-xian",
      component: () => import("@/views/PlayXian/index.vue"),
      meta: {
        title: '玩转西安_西安旅游网', // 页面标题
      },
    },
    {
      path: "/serve-you",
      name: "serve-you",
      component: () => import("@/views/ServeYou/index.vue"),
      meta: {
        title: '旅游咨询_西安旅游网', // 页面标题
      },
    },
    {
      path: "/culture-xian",
      name: "culture-xian",
      component: () => import("@/views/CultureXian/index.vue"),
      meta: {
        title: '文化西安_西安旅游网', // 页面标题
      },
    }
    ,
    {
      path: "/food-list",
      name: "food-list",
      component: () => import("@/views/FoodList/index.vue"),
      meta: {
        title: '美食推荐_西安旅游网', // 页面标题
      },
    }
    , {
      path: "/food-details",
      name: "food-details",
      component: () => import("@/views/FoodList/detail.vue"),
      meta: {
        title: '美食推荐详情_西安旅游网', // 页面标题
      },
    }
    ,
    {
      path: "/hotel-list",
      name: "hotel-list",
      component: () => import("@/views/HotelList/index.vue"),
      meta: {
        title: '酒店信息_西安旅游网', // 页面标题
      },
    }
    ,
    {
      path: "/hotel-details",
      name: "hotel-details",
      component: () => import("@/views/HotelList/detail.vue"),
      meta: {
        title: '酒店信息详情_西安旅游网', // 页面标题
      },
    }
    ,
    {
      path: "/travel-consultation-list",
      name: "travel-consultation-list",
      component: () => import("@/views/TravelConsultation/index.vue"),
      meta: {
        title: '资讯记录_西安旅游网', // 页面标题
      },
    }
    ,
    {
      path: "/scenic-list",
      name: "scenic-list",
      component: () => import("@/views/ScenicList/index.vue"),
      meta: {
        title: '旅游景区_西安旅游网', // 页面标题
      },
    }
    , {
      path: "/scenic-details",
      name: "scenic-details",
      component: () => import("@/views/ScenicList/detail.vue"),
      meta: {
        title: '旅游景区详情_西安旅游网', // 页面标题
      },
    }
    ,
    {
      path: "/shopping-list",
      name: "shopping-list",
      component: () => import("@/views/ShoppingList/index.vue"),
      meta: {
        title: '休闲购物_西安旅游网', // 页面标题
      },
    },
    {
      path: "/travel-agency-list",
      name: "travel-agency-list",
      component: () => import("@/views/TravelAgency/index.vue"),
      meta: {
        title: '旅行社查询_西安旅游网', // 页面标题
      },
    },
    {
      path: "/online",
      name: "online",
      component: () => import("@/views/online/index.vue"),
      meta: {
        title: '云游大西安_西安旅游网', // 页面标题
      },
    }
    ,
    {
      path: "/survey-details",
      name: "survey-details",
      component: () => import("@/views/SurveyDetails/index.vue"),
      meta: {
        title: '文化西安详情_西安旅游网', // 页面标题
      },
    },
    {
      path: "/lang-index",
      name: "lang-index",
      component: () => import("@/views/Lang/index.vue"),
      meta: {
        title: '首页', // 页面标题
      },
    }
    ,
    {
      path: "/lang-about",
      name: "lang-about",
      component: () => import("@/views/Lang/cultureXian/index.vue"),
      meta: {
        title: 'lang-about', // 页面标题
      },
    }   ,
    {
      path: "/lang-detail",
      name: "lang-detail",
      component: () => import("@/views/Lang/cultureXian/detail.vue"),
      meta: {
        title: 'lang-detail', // 页面标题
      },
    }
    ,
    {
      path: "/lang-consultation",
      name: "lang-consultation",
      component: () => import("@/views/Lang/consultation.vue"),
      meta: {
        title: 'lang-consultation', // 页面标题
      },
    }
    ,
    {
      path: "/lang-metro",
      name: "lang-metro",
      component: () => import("@/views/Lang/metro.vue"),
      meta: {
        title: 'lang-metro', // 页面标题
      },
    }
    ,
    {
      path: "/lang-spot",
      name: "lang-spot",
      component: () => import("@/views/Lang/Spot.vue"),
      meta: {
        title: 'lang-spot', // 页面标题
      },
    }
    ,
    {
      path: "/720full-list",
      name: "720full-list",
      component: () => import("@/views/CultureXian/fullList.vue"),
      meta: {
        title: '720全景_西安旅游网', // 页面标题
      },
    }, {
      path: "*",
      redirect: "/404",
    },
    {
      path: "/404",
      name: "404",
      component: () => import("@/views/404.vue"),
    },
  ],
  scrollBehavior(to, from, savedPosition) {
    if(to.path==from.path){
        return
    }
    if (savedPosition) {
      return savedPosition
    } else {
      return { x: 0, y: 0 }
    }
  }
})
router.beforeEach((to, from, next) => {
  // 设置页面标题
  if (to.meta.title) {
    document.title = to.meta.title;
  }
  next();
});

export default router